package com.qidian.buy.cms.controller;

import com.qidian.buy.cms.service.IContentCategoryService;
import com.qidian.buy.entity.ContentCategory;
import com.qidian.buy.util.pojo.BuyResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

/**
 * <p>
 * 内容分类 前端控制器
 * </p>
 *
 * @author 戴着假发的程序员
 * @since 2023-07-05
 */
@RestController
@CrossOrigin
@RequestMapping("/buy/contentCat")
public class ContentCategoryController {
    @Autowired
    private IContentCategoryService categoryService;

    @GetMapping("/queryByParentId")
    public BuyResult queryByParentId(Long parentId){
        return categoryService.queryByParentId(parentId);
    }
    @PostMapping("/save")
    public BuyResult save(@RequestBody ContentCategory cat){
        return categoryService.saveCat(cat);
    }
    @GetMapping("/queryById")
    public BuyResult queryById(Long parentId){
        return categoryService.queryById(parentId);
    }
    @PostMapping("/updateCat")
    public BuyResult updateCat(@RequestBody ContentCategory cat){
        return categoryService.updateCat(cat);
    }
    @GetMapping("/deleteCat")
    public BuyResult deleteCat(Long id){
        return categoryService.deleteCat(id);
    }
}
